﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 单例模式
{

    class Program
    {
       
        static void Main(string[] args)
        {

            //Singleton singleton = Singleton.CreateInstance();
            for (int i = 0; i < 10; i++)
            {
                new Action(() => {

                    Singleton singleton = Singleton.CreateInstance();
                    singleton.Show();
                }).BeginInvoke(null,null); //异步调用,会启动一个异步多线程调用 
                //Singleton singleton = new Singleton(); //每次都构造一对象，非常慢
                //singleton.Show();
            }


            Console.Read();
        }
    }
}
